//
// ManualKerning
// =============
// A Cinema 4D effector plugin to influence kerning of MoText objects
// By Andreas Block, January 19th 2012
// Mail: open@andreasblock.de
//
// For further information, see manualkerning.h
//
//------------------------------------------------------------------------
// File: manualkerning_defines.h  - declaration of defines and constants
//                                  (like e.g. default parameters)
//

#ifndef _MANUALKERNING_DEFINES_H_
#define _MANUALKERNING_DEFINES_H_

// Debug
#define MKDEBUG

// Compile switches
#define USE_FREETYPE

// Defines
#define MANUALKERNING_VERSION_MAJOR        0x00
#define MANUALKERNING_VERSION_MINOR        0x00
#define MANUALKERNING_VERSION_BUILD        0x0002

#define MANUALKERNING_MAX_FONTS            0x1000
#define MANUALKERNING_MAX_PATH_LEN         64
#define MANUALKERNING_MAX_FAMILY_LEN       32
#define MANUALKERNING_MAX_STYLE_LEN        32
#define MANUALKERNING_MAX_COMBINED_LEN     MANUALKERNING_MAX_FAMILY_LEN + MANUALKERNING_MAX_STYLE_LEN
#define MANUALKERNING_MAX_FILEPATH_LEN     MANUALKERNING_MAX_PATH_LEN + MANUALKERNING_MAX_COMBINED_LEN

#define MANUALKERNING_MAX_CHARS            0x400   // needs to be lower than difference of _BASE IDs in .res (currently 0x1000)
#define MANUALKERNING_MAX_RULES            0x80    // needs to be lower than difference of _BASE IDs in .res (currently 0x1000)

#define MANUALKERNING_DEFAULT_NAME_FAMILY  String("Arial")
#define MANUALKERNING_DEFAULT_NAME_STYLE   String("Regular")

// Parameter default values
#define PARAM_DEFAULT_AUTO_FLAG_ENABLE                  TRUE
#define PARAM_DEFAULT_AUTO_FLAG_OVERRIDE                FALSE
#define PARAM_DEFAULT_RULE_TEXT                         "  "
#define PARAM_DEFAULT_RULE_KERNING                      RCO 0.0
#define PARAM_DEFAULT_CHAR_KERNING                      RCO 0.0
#define PARAM_DEFAULT_CHAR_SIZE                         Vector(RCO 1.0)
#define PARAM_DEFAULT_CHAR_ROTATION                     Vector(RCO 0.0)
#define PARAM_DEFAULT_CHAR_OFFSET                       Vector(RCO 0.0)
#define PARAM_DEFAULT_AUTO_KERNING                      RCO 1.0
#define PARAM_DEFAULT_AUTO_FILENAME                     Filename(String(g_pFontpath) + "ARIAL.TTF")
#define PARAM_DEFAULT_RULES_NUM                         0
#define PARAM_DEFAULT_OPTION_FLAG_OFFSET_INCREMENTAL    FALSE
#define PARAM_DEFAULT_OPTION_FLAG_SIZE_INCREMENTAL      FALSE
#define PARAM_DEFAULT_OPTION_FLAG_ROTATION_INCREMENTAL  FALSE
#define PARAM_DEFAULT_OPTION_FLAG_LINEBREAK             TRUE

#ifdef USE_FREETYPE
// Some defines switching between different C4D version branches
#if  (API_VERSION >= 13000)
#define  FontTableInit() FontTableInitR13()
#define  FontAutoSetFilename(bc1, bc2, sStatus)   FontAutoSetFilenameR13(bc1, bc2, sStatus)
#else
#define  FontTableInit()
#define  FontAutoSetFilename(bc1, bc2, sStatus)
#endif
#endif

// Constants
#pragma region ARR_RULE_DEFAULTS
static const char ARR_RULE_DEFAULTS[][16] = { "Av Aw",  // a few example rules from Wikipedia
                                              "AV AW",
                                              "LT",
                                              "LV",
                                              "Ly",
                                              "Ta Te To Ty",
                                              "T. V. Y.",
                                              "Va Ve Vo",
                                              "Ya Ye Yo" };
#pragma endregion ARR_RULE_DEFAULTS

#pragma region ARR_STYLE_IDS
static const LONG ARR_STYLE_IDS[] = { MANUALKERNING_STRING_STYLE_REGULAR,
                                      MANUALKERNING_STRING_STYLE_BOLD,
                                      MANUALKERNING_STRING_STYLE_DEMIBOLD,
                                      MANUALKERNING_STRING_STYLE_ITALIC };
#pragma endregion ARR_RULE_DEFAULTS

#ifdef USE_FREETYPE
#pragma region ARR_STYLE_NAMES_FT2
// Has to match ARR_STYLE_IDS[]
static const char ARR_STYLE_NAMES_FT2[][16] = { "Regular",
                                                "Bold",
                                                "Demibold",
                                                "Italic" };
#pragma endregion ARR_STYLE_NAMES_FT2
#endif

// Macros
#pragma region MACRO_DECLARATIONS

#pragma region MACRO_GET_FONT_PATH
#ifdef USE_FREETYPE
#if defined(_WIN32) 
#define GET_FONT_PATH()                                               \
   do {                                                               \
     String sFontpath;                                                \
     GetSystemEnvironmentVariable("windir", sFontpath);               \
     sFontpath += "\\Fonts\\";                                        \
     sFontpath.GetCString(g_pFontpath, sFontpath.GetCStringLen()+1);  \
   } while (0)
#endif
#if defined(_APPLE_) && defined(_MACH_)
#define GET_FONT_PATH() g_sFontpath = "/Library/Fonts/"  // TODO: correct???  // MAC_PORT_TODO
#endif
#endif
#pragma endregion MACRO_GET_FONT_PATH

#pragma endregion MACRO_DECLARATIONS

#endif _MANUALKERNING_DEFINES_H_
